cognitiveclass.ai logo

Extracting and Visualizing Stock Data

Description

Extracting essential data from a dataset and displaying it is a necessary part of data science; therefore individuals can make correct decisions based on the data. In this assignment, you will extract some stock data, you will then display this data in a graph.

Table of Contents

  • Define a Function that Makes a Graph
  • Question 1: Use yfinance to Extract Stock Data
  • Question 2: Use Webscraping to Extract Tesla Revenue Data
  • Question 3: Use yfinance to Extract Stock Data
  • Question 4: Use Webscraping to Extract GME Revenue Data
  • Question 5: Plot Tesla Stock Graph
  • Question 6: Plot GameStop Stock Graph

Estimated Time Needed: 30 min


In [1]:
!pip install yfinance==0.1.67
#!pip install pandas==1.3.3
#!pip install requests==2.26.0
!mamba install bs4==4.10.0 -y
!mamba install nbformat==5.5.0 -y
#!pip install plotly==5.3.1
Requirement already satisfied: yfinance==0.1.67 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (0.1.67)
Requirement already satisfied: pandas>=0.24 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from yfinance==0.1.67) (1.3.5)
Requirement already satisfied: requests>=2.20 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from yfinance==0.1.67) (2.28.1)
Requirement already satisfied: lxml>=4.5.1 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from yfinance==0.1.67) (4.9.1)
Requirement already satisfied: multitasking>=0.0.7 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from yfinance==0.1.67) (0.0.11)
Requirement already satisfied: numpy>=1.15 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from yfinance==0.1.67) (1.21.6)
Requirement already satisfied: python-dateutil>=2.7.3 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from pandas>=0.24->yfinance==0.1.67) (2.8.2)
Requirement already satisfied: pytz>=2017.3 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from pandas>=0.24->yfinance==0.1.67) (2022.2.1)
Requirement already satisfied: charset-normalizer<3,>=2 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests>=2.20->yfinance==0.1.67) (2.1.1)
Requirement already satisfied: certifi>=2017.4.17 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests>=2.20->yfinance==0.1.67) (2022.9.24)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests>=2.20->yfinance==0.1.67) (1.26.11)
Requirement already satisfied: idna<4,>=2.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from requests>=2.20->yfinance==0.1.67) (3.4)
Requirement already satisfied: six>=1.5 in /home/jupyterlab/conda/envs/python/lib/python3.7/site-packages (from python-dateutil>=2.7.3->pandas>=0.24->yfinance==0.1.67) (1.16.0)

                  __    __    __    __
                 /  \  /  \  /  \  /  \
                /    \/    \/    \/    \
███████████████/  /██/  /██/  /██/  /████████████████████████
              /  / \   / \   / \   / \  \____
             /  /   \_/   \_/   \_/   \    o \__,
            / _/                       \_____/  `
            |/
        ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
        ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
        ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
        ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
        ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
        ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝

        mamba (0.15.3) supported by @QuantStack

        GitHub:  https://github.com/mamba-org/mamba
        Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████


Looking for: ['bs4==4.10.0']

pkgs/main/linux-64       [>                   ] (--:--) No change
pkgs/main/linux-64       [====================] (00m:00s) No change
pkgs/main/noarch         [>                   ] (--:--) No change
pkgs/main/noarch         [====================] (00m:00s) No change
pkgs/r/linux-64          [>                   ] (--:--) No change
pkgs/r/linux-64          [====================] (00m:00s) No change
pkgs/r/noarch            [>                   ] (--:--) No change
pkgs/r/noarch            [====================] (00m:00s) No change

Pinned packages:
  - python 3.7.*


Transaction

  Prefix: /home/jupyterlab/conda/envs/python

  All requested packages already installed


                  __    __    __    __
                 /  \  /  \  /  \  /  \
                /    \/    \/    \/    \
███████████████/  /██/  /██/  /██/  /████████████████████████
              /  / \   / \   / \   / \  \____
             /  /   \_/   \_/   \_/   \    o \__,
            / _/                       \_____/  `
            |/
        ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
        ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
        ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
        ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
        ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
        ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝

        mamba (0.15.3) supported by @QuantStack

        GitHub:  https://github.com/mamba-org/mamba
        Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████


Looking for: ['nbformat==5.5.0']

pkgs/main/linux-64       Using cache
pkgs/main/noarch         Using cache
pkgs/r/linux-64          Using cache
pkgs/r/noarch            Using cache

Pinned packages:
  - python 3.7.*


Transaction

  Prefix: /home/jupyterlab/conda/envs/python

  Updating specs:

   - nbformat==5.5.0
   - ca-certificates
   - certifi
   - openssl


  Package                  Version  Build           Channel                  Size
───────────────────────────────────────────────────────────────────────────────────
  Install:
───────────────────────────────────────────────────────────────────────────────────

  + attrs                   21.4.0  pyhd3eb1b0_0    pkgs/main/noarch        51 KB
  + importlib_metadata       1.5.0  py37_0          pkgs/main/linux-64      48 KB
  + importlib_resources      5.2.0  pyhd3eb1b0_1    pkgs/main/noarch        21 KB
  + jsonschema              4.16.0  py37h06a4308_0  pkgs/main/linux-64     127 KB
  + nbformat                 5.5.0  py37h06a4308_0  pkgs/main/linux-64     128 KB
  + pkgutil-resolve-name    1.3.10  py37h06a4308_0  pkgs/main/linux-64       9 KB
  + pyrsistent              0.18.0  py37heee7806_0  pkgs/main/linux-64      95 KB
  + python-fastjsonschema   2.16.2  py37h06a4308_0  pkgs/main/linux-64     230 KB

  Summary:

  Install: 8 packages

  Total download: 709 KB

───────────────────────────────────────────────────────────────────────────────────

Downloading  [>                                        ] (00m:00s)  118.61 KB/s
Extracting   [>                                                      ] (--:--) 
Finished pkgutil-resolve-name                 (00m:00s)               9 KB    118 KB/s
Downloading  [>                                        ] (00m:00s)  118.61 KB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [>                                        ] (00m:00s)  118.61 KB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [>                                        ] (00m:00s)  118.61 KB/s
Extracting   [>                                                      ] (--:--) 
Downloading  [>                                        ] (00m:00s)  118.61 KB/s
Extracting   [====>                                    ] (00m:00s)        1 / 8
Downloading  [===>                                     ] (00m:00s)  671.82 KB/s
Extracting   [====>                                    ] (00m:00s)        1 / 8
Finished attrs                                (00m:00s)              51 KB    577 KB/s
Downloading  [===>                                     ] (00m:00s)  671.82 KB/s
Extracting   [====>                                    ] (00m:00s)        1 / 8
Downloading  [===>                                     ] (00m:00s)  671.82 KB/s
Extracting   [====>                                    ] (00m:00s)        1 / 8
Downloading  [===>                                     ] (00m:00s)  671.82 KB/s
Extracting   [====>                                    ] (00m:00s)        1 / 8
Downloading  [========>                                ] (00m:00s)    1.61 MB/s
Extracting   [====>                                    ] (00m:00s)        1 / 8
Finished pyrsistent                           (00m:00s)              95 KB   1022 KB/s
Downloading  [========>                                ] (00m:00s)    1.61 MB/s
Extracting   [====>                                    ] (00m:00s)        1 / 8
Downloading  [========>                                ] (00m:00s)    1.61 MB/s
Extracting   [====>                                    ] (00m:00s)        1 / 8
Downloading  [=========>                               ] (00m:00s)    1.77 MB/s
Extracting   [====>                                    ] (00m:00s)        1 / 8
Downloading  [=========>                               ] (00m:00s)    1.77 MB/s
Extracting   [==========>                              ] (00m:00s)        2 / 8
Downloading  [=========>                               ] (00m:00s)    1.77 MB/s
Extracting   [==========>                              ] (00m:00s)        2 / 8
Finished importlib_resources                  (00m:00s)              21 KB    225 KB/s
Downloading  [=========>                               ] (00m:00s)    1.77 MB/s
Extracting   [==========>                              ] (00m:00s)        2 / 8
Downloading  [=========>                               ] (00m:00s)    1.77 MB/s
Extracting   [==========>                              ] (00m:00s)        2 / 8
Downloading  [=================>                       ] (00m:00s)    2.49 MB/s
Extracting   [==========>                              ] (00m:00s)        2 / 8
Downloading  [====================>                    ] (00m:00s)    2.83 MB/s
Extracting   [==========>                              ] (00m:00s)        2 / 8
Finished jsonschema                           (00m:00s)             127 KB      1 MB/s
Downloading  [====================>                    ] (00m:00s)    2.83 MB/s
Extracting   [==========>                              ] (00m:00s)        2 / 8
Downloading  [====================>                    ] (00m:00s)    2.83 MB/s
Extracting   [===============>                         ] (00m:00s)        3 / 8
Downloading  [===========================>             ] (00m:00s)    3.46 MB/s
Extracting   [===============>                         ] (00m:00s)        3 / 8
Finished importlib_metadata                   (00m:00s)              48 KB    397 KB/s
Downloading  [===========================>             ] (00m:00s)    3.46 MB/s
Extracting   [===============>                         ] (00m:00s)        3 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [===============>                         ] (00m:00s)        3 / 8
Finished python-fastjsonschema                (00m:00s)             230 KB      2 MB/s
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [===============>                         ] (00m:00s)        3 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [===============>                         ] (00m:00s)        3 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [===============>                         ] (00m:00s)        3 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [===============>                         ] (00m:00s)        3 / 8
Finished nbformat                             (00m:00s)             128 KB    957 KB/s
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [===============>                         ] (00m:00s)        3 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [===============>                         ] (00m:00s)        3 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [===============>                         ] (00m:00s)        3 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [====================>                    ] (00m:00s)        4 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [====================>                    ] (00m:00s)        4 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [=========================>               ] (00m:00s)        5 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [=========================>               ] (00m:00s)        5 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [==============================>          ] (00m:00s)        6 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [==============================>          ] (00m:00s)        6 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [===================================>     ] (00m:00s)        7 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [===================================>     ] (00m:00s)        7 / 8
Downloading  [=========================================] (00m:00s)    4.98 MB/s
Extracting   [=========================================] (00m:00s)        8 / 8
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
In [2]:
import yfinance as yf
import pandas as pd
import requests
from bs4 import BeautifulSoup
import plotly.graph_objects as go
from plotly.subplots import make_subplots

Define Graphing Function¶

In this section, we define the function make_graph. You don't have to know how the function works, you should only care about the inputs. It takes a dataframe with stock data (dataframe must contain Date and Close columns), a dataframe with revenue data (dataframe must contain Date and Revenue columns), and the name of the stock.

In [3]:
def make_graph(stock_data, revenue_data, stock):
    fig = make_subplots(rows=2, cols=1, shared_xaxes=True, subplot_titles=("Historical Share Price", "Historical Revenue"), vertical_spacing = .3)
    stock_data_specific = stock_data[stock_data.Date <= '2021--06-14']
    revenue_data_specific = revenue_data[revenue_data.Date <= '2021-04-30']
    fig.add_trace(go.Scatter(x=pd.to_datetime(stock_data_specific.Date, infer_datetime_format=True), y=stock_data_specific.Close.astype("float"), name="Share Price"), row=1, col=1)
    fig.add_trace(go.Scatter(x=pd.to_datetime(revenue_data_specific.Date, infer_datetime_format=True), y=revenue_data_specific.Revenue.astype("float"), name="Revenue"), row=2, col=1)
    fig.update_xaxes(title_text="Date", row=1, col=1)
    fig.update_xaxes(title_text="Date", row=2, col=1)
    fig.update_yaxes(title_text="Price ($US)", row=1, col=1)
    fig.update_yaxes(title_text="Revenue ($US Millions)", row=2, col=1)
    fig.update_layout(showlegend=False,
    height=900,
    title=stock,
    xaxis_rangeslider_visible=True)
    fig.show()

Question 1: Use yfinance to Extract Stock Data¶

Using the Ticker function enter the ticker symbol of the stock we want to extract data on to create a ticker object. The stock is Tesla and its ticker symbol is TSLA.

In [4]:
tesla = yf.Ticker("TSLA")

Using the ticker object and the function history extract stock information and save it in a dataframe named tesla_data. Set the period parameter to max so we get information for the maximum amount of time.

In [5]:
tesla_data = tesla.history(period="max")

Reset the index using the reset_index(inplace=True) function on the tesla_data DataFrame and display the first five rows of the tesla_data dataframe using the head function. Take a screenshot of the results and code from the beginning of Question 1 to the results below.

In [6]:
tesla_data.reset_index(inplace=True)
tesla_data.head()
Out[6]:
Date Open High Low Close Volume Dividends Stock Splits
0 2010-06-29 1.266667 1.666667 1.169333 1.592667 281494500 0 0.0
1 2010-06-30 1.719333 2.028000 1.553333 1.588667 257806500 0 0.0
2 2010-07-01 1.666667 1.728000 1.351333 1.464000 123282000 0 0.0
3 2010-07-02 1.533333 1.540000 1.247333 1.280000 77097000 0 0.0
4 2010-07-06 1.333333 1.333333 1.055333 1.074000 103003500 0 0.0

Question 2: Use Webscraping to Extract Tesla Revenue Data¶

Use the requests library to download the webpage https://www.macrotrends.net/stocks/charts/TSLA/tesla/revenue. Save the text of the response as a variable named html_data.

In [7]:
url = "https://www.macrotrends.net/stocks/charts/TSLA/tesla/revenue"
html_data = requests.get(url).text

Parse the html data using beautiful_soup.

In [8]:
soup = BeautifulSoup(html_data, "html.parser")

Using BeautifulSoup or the read_html function extract the table with Tesla Quarterly Revenue and store it into a dataframe named tesla_revenue. The dataframe should have columns Date and Revenue.

Click here if you need help locating the table

Below is the code to isolate the table, you will now need to loop through the rows and columns like in the previous lab

soup.find_all("tbody")[1]

If you want to use the read_html function the table is located at index 1


In [9]:
tables = soup.find_all('table')
In [10]:
for index,table in enumerate(tables):
    if ("Tesla Quarterly Revenue" in str(table)):
        table_index = index
print(table_index)
1
In [11]:
tesla_revenue = pd.DataFrame(columns=["Date", "Revenue"])

for row in tables[1].tbody.find_all("tr"):
    col = row.find_all("td")
    if (col != []):
        date = col[0].text
        revenue = col[1].text
        tesla_revenue = tesla_revenue.append({"Date":date, "Revenue":revenue}, ignore_index=True)

tesla_revenue
Out[11]:
Date Revenue
0 2022-06-30 $16,934
1 2022-03-31 $18,756
2 2021-12-31 $17,719
3 2021-09-30 $13,757
4 2021-06-30 $11,958
5 2021-03-31 $10,389
6 2020-12-31 $10,744
7 2020-09-30 $8,771
8 2020-06-30 $6,036
9 2020-03-31 $5,985
10 2019-12-31 $7,384
11 2019-09-30 $6,303
12 2019-06-30 $6,350
13 2019-03-31 $4,541
14 2018-12-31 $7,226
15 2018-09-30 $6,824
16 2018-06-30 $4,002
17 2018-03-31 $3,409
18 2017-12-31 $3,288
19 2017-09-30 $2,985
20 2017-06-30 $2,790
21 2017-03-31 $2,696
22 2016-12-31 $2,285
23 2016-09-30 $2,298
24 2016-06-30 $1,270
25 2016-03-31 $1,147
26 2015-12-31 $1,214
27 2015-09-30 $937
28 2015-06-30 $955
29 2015-03-31 $940
30 2014-12-31 $957
31 2014-09-30 $852
32 2014-06-30 $769
33 2014-03-31 $621
34 2013-12-31 $615
35 2013-09-30 $431
36 2013-06-30 $405
37 2013-03-31 $562
38 2012-12-31 $306
39 2012-09-30 $50
40 2012-06-30 $27
41 2012-03-31 $30
42 2011-12-31 $39
43 2011-09-30 $58
44 2011-06-30 $58
45 2011-03-31 $49
46 2010-12-31 $36
47 2010-09-30 $31
48 2010-06-30 $28
49 2010-03-31 $21
50 2009-12-31
51 2009-09-30 $46
52 2009-06-30 $27

Execute the following line to remove the comma and dollar sign from the Revenue column.

In [12]:
tesla_revenue["Revenue"] = tesla_revenue['Revenue'].str.replace(',|\$',"")
/home/jupyterlab/conda/envs/python/lib/python3.7/site-packages/ipykernel_launcher.py:1: FutureWarning: The default value of regex will change from True to False in a future version.
  """Entry point for launching an IPython kernel.

Execute the following lines to remove an null or empty strings in the Revenue column.

In [13]:
tesla_revenue.dropna(inplace=True)

tesla_revenue = tesla_revenue[tesla_revenue['Revenue'] != ""]

Display the last 5 row of the tesla_revenue dataframe using the tail function. Take a screenshot of the results.

In [14]:
tesla_revenue.tail()
Out[14]:
Date Revenue
47 2010-09-30 31
48 2010-06-30 28
49 2010-03-31 21
51 2009-09-30 46
52 2009-06-30 27

Question 3: Use yfinance to Extract Stock Data¶

Using the Ticker function enter the ticker symbol of the stock we want to extract data on to create a ticker object. The stock is GameStop and its ticker symbol is GME.

In [15]:
GameStop = yf.Ticker("GME")

Using the ticker object and the function history extract stock information and save it in a dataframe named gme_data. Set the period parameter to max so we get information for the maximum amount of time.

In [16]:
gme_data = GameStop.history(period="max")

Reset the index using the reset_index(inplace=True) function on the gme_data DataFrame and display the first five rows of the gme_data dataframe using the head function. Take a screenshot of the results and code from the beginning of Question 3 to the results below.

In [17]:
gme_data.reset_index(inplace=True)
gme_data.head()
Out[17]:
Date Open High Low Close Volume Dividends Stock Splits
0 2002-02-13 1.620129 1.693350 1.603296 1.691667 76216000 0.0 0.0
1 2002-02-14 1.712707 1.716074 1.670626 1.683250 11021600 0.0 0.0
2 2002-02-15 1.683250 1.687458 1.658001 1.674834 8389600 0.0 0.0
3 2002-02-19 1.666418 1.666418 1.578047 1.607504 7410400 0.0 0.0
4 2002-02-20 1.615920 1.662210 1.603296 1.662210 6892800 0.0 0.0

Question 4: Use Webscraping to Extract GME Revenue Data¶

Use the requests library to download the webpage https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0220EN-SkillsNetwork/labs/project/stock.html. Save the text of the response as a variable named html_data.

In [18]:
url2 = "https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-PY0220EN-SkillsNetwork/labs/project/stock.html"
html_data = requests.get(url2).text

Parse the html data using beautiful_soup.

In [19]:
soup = BeautifulSoup(html_data, "html.parser")

Using BeautifulSoup or the read_html function extract the table with GameStop Quarterly Revenue and store it into a dataframe named gme_revenue. The dataframe should have columns Date and Revenue. Make sure the comma and dollar sign is removed from the Revenue column using a method similar to what you did in Question 2.

Click here if you need help locating the table

Below is the code to isolate the table, you will now need to loop through the rows and columns like in the previous lab

soup.find_all("tbody")[1]

If you want to use the read_html function the table is located at index 1


In [20]:
tables = soup.find_all('table')
In [21]:
for index,table in enumerate(tables):
    if ("GameStop Quarterly Revenue" in str(table)):
        table_index = index
print(table_index)
1
In [22]:
gme_revenue = pd.DataFrame(columns=["Date", "Revenue"])

for row in tables[1].tbody.find_all("tr"):
    col = row.find_all("td")
    if (col != []):
        date = col[0].text
        revenue = col[1].text
        gme_revenue = gme_revenue.append({"Date":date, "Revenue":revenue}, ignore_index=True)

gme_revenue
Out[22]:
Date Revenue
0 2020-04-30 $1,021
1 2020-01-31 $2,194
2 2019-10-31 $1,439
3 2019-07-31 $1,286
4 2019-04-30 $1,548
... ... ...
57 2006-01-31 $1,667
58 2005-10-31 $534
59 2005-07-31 $416
60 2005-04-30 $475
61 2005-01-31 $709

62 rows × 2 columns

In [23]:
gme_revenue["Revenue"] = gme_revenue['Revenue'].str.replace(',|\$',"")
/home/jupyterlab/conda/envs/python/lib/python3.7/site-packages/ipykernel_launcher.py:1: FutureWarning: The default value of regex will change from True to False in a future version.
  """Entry point for launching an IPython kernel.
In [24]:
gme_revenue.dropna(inplace=True)

gme_revenue = gme_revenue[gme_revenue['Revenue'] != ""]

Display the last five rows of the gme_revenue dataframe using the tail function. Take a screenshot of the results.

In [25]:
gme_revenue.tail()
Out[25]:
Date Revenue
57 2006-01-31 1667
58 2005-10-31 534
59 2005-07-31 416
60 2005-04-30 475
61 2005-01-31 709

Question 5: Plot Tesla Stock Graph¶

Use the make_graph function to graph the Tesla Stock Data, also provide a title for the graph. The structure to call the make_graph function is make_graph(tesla_data, tesla_revenue, 'Tesla'). Note the graph will only show data upto June 2021.

In [26]:
make_graph(tesla_data, tesla_revenue, 'Tesla')

Question 6: Plot GameStop Stock Graph¶

Use the make_graph function to graph the GameStop Stock Data, also provide a title for the graph. The structure to call the make_graph function is make_graph(gme_data, gme_revenue, 'GameStop'). Note the graph will only show data upto June 2021.

In [27]:
make_graph(gme_data, gme_revenue, 'GameStop')

About the Authors:

Joseph Santarcangelo has a PhD in Electrical Engineering, his research focused on using machine learning, signal processing, and computer vision to determine how videos impact human cognition. Joseph has been working for IBM since he completed his PhD.

Azim Hirjani

Change Log¶

| Date (YYYY-MM-DD) | Version | Changed By | Change Description | | ----------------- | ------- | ------------- | --------------------------- | | 2022-02-28 | 1.2 | Lakshmi Holla | Changed the URL of GameStop | | 2020-11-10 | 1.1 | Malika Singla | Deleted the Optional part | | 2020-08-27 | 1.0 | Malika Singla | Added lab to GitLab |


© IBM Corporation 2020. All rights reserved.